﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Collections;
using Syncfusion.Mvc.Grid;
using Syncfusion.DocIO.DLS;
using Syncfusion.Pdf;
using Syncfusion.XlsIO;

namespace MvcApplication4.Controllers
{
    public partial class GridController : Controller
    {
        
        public ActionResult Exporting()
        {
            var data = new MvcApplication4.Models.StudentDataContext().Student.Take(100).ToList();
            ViewData["ProductName"] = "Grid";
            return View(data);

        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Exporting(PagingParams args)
        {
            IEnumerable data = new MvcApplication4.Models.StudentDataContext().Student.Take(100).ToList();
            return data.GridActions<MvcApplication4.Models.Student>();
        }

        /// <summary>
        /// Exports to excel.
        /// </summary>
        /// <param name="args">Contains paging information</param>
        /// <returns>Records of Grid for ExcelExport </returns>
        public ActionResult ExportToExcel(PagingParams args)
        {
            var data = new MvcApplication4.Models.StudentDataContext().Student.Take(200).ToList();
            return data.GridExportToExcel<MvcApplication4.Models.Student>("GridExcel.xlsx", ExcelVersion.Excel2007, args.ExportOption);
        }

        /// <summary>
        /// Exports to word.
        /// </summary>
        /// <param name="args">Contains paging information</param>
        /// <returns>Records of Grid for Word</returns>
        public ActionResult ExportToWord(PagingParams args)
        {
            var data = new MvcApplication4.Models.StudentDataContext().Student.Take(200).ToList();
            return data.GridExportToWord<MvcApplication4.Models.Student>("GridWord.doc", DocumentVersion.Word2007, args.ExportOption);
        }

        /// <summary>
        /// Exports to PDF.
        /// </summary>
        /// <param name="args">Contains paging information</param>
        /// <returns>Records of Grid for Word</returns>
        public ActionResult ExportToPDF(PagingParams args)
        {
            var data = new MvcApplication4.Models.StudentDataContext().Student.Take(200).ToList();
            return data.GridExportToPDF<MvcApplication4.Models.Student>("GridPDF.pdf", PdfVersion.Version1_7, args.ExportOption);
        }

    }
}
